package cn.ecnu.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Set;

@Entity
@Table(name = "journal")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "期刊实体类")
public class Journal implements Serializable {

    private static final long serialVersionUID = -6767885414660070855L;

    @Id
    @TableId(type = IdType.AUTO)
    @Column(name = "journal_id")
    @ApiModelProperty(value = "期刊ID", example = "1")
    private Long journalId;

    @Column(name = "title", nullable = false)
    @ApiModelProperty(value = "期刊标题", required = true, example = "Journal of Artificial Intelligence Research")
    private String title;

    @ApiModelProperty(value = "Short name of the journal")
    @Column(name = "short_name")
    private String shortName;

    @Column(name = "description")
    @ApiModelProperty(value = "期刊描述", example = "This journal covers research in artificial intelligence.")
    private String description;

    @Column(name = "impact_factor")
    @ApiModelProperty(value = "影响因子", example = "5.123")
    private Float impactFactor;

    @ElementCollection(targetClass = String.class)
    @CollectionTable(name = "journal_categories", joinColumns = @JoinColumn(name = "journal_id"))
    @Column(name = "categories")
    @ApiModelProperty(value = "期刊类别", example = "[\"Artificial Intelligence\", \"Machine Learning\"]")
    private Set<String> categories;

    @Column(name = "ccf_level", nullable = false)
    @ApiModelProperty(value = "CCF分级", required = true, example = "A")
    private String ccfLevel;

    @Column(name = "submission_guidelines")
    @ApiModelProperty(value = "投稿指南", example = "Please follow the submission guidelines provided on the website.")
    private String submissionGuidelines;

    @Column(name = "journal_url")
    @ApiModelProperty(value = "期刊网址", example = "http://www.example.com")
    private String journalUrl;

    @Column(name = "views", nullable = false, columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "浏览数", required = true, example = "100")
    private int views;

    @Column(name = "follows", nullable = false, columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "关注数", required = true, example = "50")
    private int follows;

    @Column(name = "created_at", nullable = false, updatable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "创建时间", required = true, example = "2024-06-11 06:40:56")
    private Date createdAt;

    @Column(name = "updated_at", nullable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "更新时间", required = true, example = "2024-06-11 06:40:56")
    private Date updatedAt;
}
